package www.bplead.com.mydemo.activity;

import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import www.bplead.com.mydemo.R;
import www.bplead.com.mydemo.widget.CustomDialog;

public class CustomDialogActivity extends AppCompatActivity implements View.OnClickListener{

    private static final String TAG = "CustomDialogActivity";

    Button dialogBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.custom_dialog);

        dialogBtn = (Button) this.findViewById(R.id.btn_open_dialog);
        dialogBtn.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_open_dialog:
                CustomDialog.Builder customDialog = new CustomDialog.Builder(this);
                customDialog.setMessage("这个就是自定义的提示框");
                customDialog.setTitle("提示");
                customDialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        //设置你的操作事项
                        Toast.makeText(CustomDialogActivity.this,"彪悍的人生不需要解释",Toast.LENGTH_SHORT).show();
                    }
                });

                customDialog.setNegativeButton("取消",
                        new android.content.DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                            }
                        });

                customDialog.setCancelable(false);
                customDialog.create().show();
                break;
        }
    }

}
